home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARASAN_S.ZIP / MATERIAL.H < prev    next >
C/C++ Source or Header  |  1994-05-08  |  937b  |  60 lines

  1. // Copyright 1994 by Jon Dart.  All Rights Reserved.
  2.  
  3. #ifndef _MATERIAL_H
  4. #define _MATERIAL_H
  5.  
  6. #include "types.h"
  7. #include "piece.h"
  8.  
  9. class Material
  10. {
  11.     friend class Board;
  12. public:
  13.     Material()
  14.     {
  15.         info = total = 0;
  16.     }
  17.     
  18.     void add_piece(const Piece::PieceType);
  19.  
  20.     void remove_piece(const Piece::PieceType);
  21.  
  22.     // return the number of pieces of the given type:
  23.     unsigned count(const Piece::PieceType) const;
  24.  
  25.     // return the total material value:
  26.     int16 value() const
  27.     {
  28.         return total;
  29.     }
  30.     
  31.     uint16 infobits() const
  32.     {
  33.         return info;
  34.     }
  35.     
  36.     // return the total number of pieces (excluding pawns and king)
  37.     unsigned piece_count() const;
  38.  
  39.     // True if only king and pawns:
  40.     Boolean no_pieces() const
  41.     {
  42.         return info & 0x7ff8;
  43.     }
  44.     
  45.     // True if bare king:
  46.     Boolean king_only() const
  47.     {
  48.         return (info & 0x7fff) == 0;
  49.     }
  50.     
  51. private:
  52.     void clear();
  53.  
  54.     int16 total;
  55.     int16 info;
  56. };
  57.  
  58. #endif
  59.  
  60.